package cn.iocoder.yudao.module.member.agency.controller.admin;

import cn.iocoder.yudao.framework.business.audit.controller.AuditController;
import cn.iocoder.yudao.framework.business.audit.pojo.form.AuditSaveDTO;
import cn.iocoder.yudao.framework.business.basic.controller.DetailController;
import cn.iocoder.yudao.framework.business.basic.controller.PageController;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.api.member.agency.vo.AgencyApplyVO;
import cn.iocoder.yudao.module.member.agency.service.AgencyApplyService;
import cn.iocoder.yudao.module.member.agency.vo.AgencyApplyQueryDTO;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 招商人员申请")
@RestController
@RequestMapping("/member/agency-apply")
@Validated
public class AgencyApplyController implements DetailController<AgencyApplyVO, Long>, PageController<AgencyApplyVO, AgencyApplyQueryDTO>, AuditController {

    @Resource
    private AgencyApplyService agencyApplyService;

    @PreAuthorize("@ss.hasAnyRoles('super_admin', 'platform_admin', 'tenant_admin')")
    @Override
    public CommonResult<Boolean> updateAudit(AuditSaveDTO reqVO) {
        agencyApplyService.updateAudit(reqVO);
        return success(true);
    }

    @PreAuthorize("@ss.hasPermission('member:agency:apply')")
    @Override
    public CommonResult<AgencyApplyVO> getDetail(Long id) {
        return success(agencyApplyService.getDetail(id));
    }

    @PreAuthorize("@ss.hasPermission('member:agency:apply')")
    @Override
    public CommonResult<PageResult<AgencyApplyVO>> getPage(Integer pageNo, Integer pageSize, AgencyApplyQueryDTO param) {
        return success(agencyApplyService.getPage(pageNo, pageSize, param));
    }

}
